Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

301
Views
The Array is empty - foreach() does not seam to work || The values does not get passed into the loop

const filteredOptions = _.filter(grantedValuesFinal, o => o.numberOfShareOptionAwardGranted > 0);

let filteredArray = []; 
filteredOptions.forEach(function(item, i){
  
  let existing = filteredArray.filter(function(o, i) {
    const dateNew = luxon.DateTime.fromISO(o.grantDate);
    const dateExsisting = luxon.DateTime.fromISO(item.grantDate);

    return o.grantDate == item.grantDate; 
  });

  if (existing.length) {
    let existingIndex = filteredArray.indexOf(existing[0]);
    if(item.typeOfEquity == "Shares") filteredArray[existingIndex].numberOfShareOptionAwardGrantedShares += item.numberOfShareOptionAwardGranted;  
    if(item.typeOfEquity == "Options") filteredArray[existingIndex].numberOfShareOptionAwardGrantedOptions += item.numberOfShareOptionAwardGranted;  
    
  } else {
      let numberOfShareOptionAwardGrantedShares = 0, numberOfShareOptionAwardGrantedOptions = 0;
      if(item.typeOfEquity == "Shares") numberOfShareOptionAwardGrantedShares += item.numberOfShareOptionAwardGranted; 
      if(item.typeOfEquity == "Options") numberOfShareOptionAwardGrantedOptions += item.numberOfShareOptionAwardGranted; 
      filteredArray.push({grantDate: item.grantDate, numberOfShareOptionAwardGrantedShares: numberOfShareOptionAwardGrantedShares, numberOfShareOptionAwardGrantedOptions: numberOfShareOptionAwardGrantedOptions }); 
  }
}) 

The very first line of the code does not pass any value, due to which filteredOptions and array is empty. What changes has to be done ? Please help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The filteredOptions array always stayed NULL as the grantedValuesFinal was only filtering out NULL values.

I was able to work out the code by placing !=NULL and got the non-null values. Thank you all for your insights

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!